class ConsultaOption < Consulta
  def self.options(orgao,nivel,ativa,page)
    @orgao = orgao
    @nivel = nivel
    @ativa = ativa
    @page = page
    @options ||= find_options
  end
  
  def self.find_options
    Option.paginate :page => @page, :conditions => conditions,:per_page => 8
  end
  
  def self.orgao_conditions
    ["orgao = ?",@orgao] unless @orgao.blank?
  end
  
  def self.nivel_conditions
    ["nivel = ?",@nivel] unless @nivel.blank?
  end

  def self.ativa_conditions
    ["ativa = ?",@ativa] unless @ativa.blank?
  end
end
